package com.sjc.springbootdemo.dao.impl;

import com.sjc.springbootdemo.dao.UserDAO;
import com.sjc.springbootdemo.domain.User;
import com.sjc.springbootdemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Classname UserDAOImpl
 * @Description 用户管理模块的DAO组件实现类
 * @Date 2020/4/23 15:01
 * @Created by SangJiacun
 */
@Repository
public class UserDAOImpl implements UserDAO {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> listUsers() {
        return userMapper.listUsers();
    }

    @Override
    public User getUserById(Long userId) {
        return userMapper.getUserById(userId);
    }

    @Override
    public Long saveUser(User user) {
        userMapper.saveUser(user);
        return user.getUserId();
    }

    @Override
    public Integer updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public Integer removeUser(Long userId) {
        return userMapper.removeUser(userId);
    }
}
